

#region Using Directives
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using Hoo.Windows.Shell.Menu;

#endregion


namespace Hoo.Windows.Shell {




    /// <summary>
    /// Inherited from <code>ContextMenu</code>, insert new menus to Windows Context Menu.
    /// </summary>
    [Guid("64F9B381-9676-4f50-A4AA-DCF187067D30"), ComVisible(true)]
    public class PathToyContextMenu : ContextMenu {
      
        protected override int InsertMenus(uint hMenu, uint iMenu, MenuItem mainMenu) {
            int id = FirstCommandId;
            // Add a separator
            MenuItem.NewMenuSeperator().Register(hMenu, (uint)iMenu + 1);


            // Populate the popup menu with file-specific items
            id = PopulateMenu(mainMenu.SubMenuHandler, ++id);
            mainMenu.Register(hMenu, (uint)iMenu + 2);

            // Add a separator
            MenuItem.NewMenuSeperator().Register(hMenu, (uint)iMenu + 3);

            return id;
        }

        /// <summary>
        ///     Populating the menu
        /// </summary>
        /// <param name="hMenu"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        int PopulateMenu(int hMenu, int id) {

            if (MenuItems == null) MenuItems = new List<MenuItem>();
            else MenuItems.Clear();

            uint position = 0;

            MenuItems.Add(new CommandHereMenu(id++));
            MenuItems.Add(new CopyFullPath(id++));
            MenuItems.Add(new CopyFileName(id++));

            foreach (MenuItem item in MenuItems) {
                item.Register((uint)hMenu, position++);
            }


            return id;
        }
    }
}
